import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

if __name__ == '__main__':
    """计院23届本科生毕业去向占比图"""
    df = pd.read_csv('../lnjydw.csv')
    df = df[df['school'].isin(['计算机学院'])]
    df = df[df['grade'].isin(['2023届'])]
    df = df[df['education'].isin(['本科'])]
    destinations, labels = zip(*[(data['number'].sum(), destination) for destination, data in df.groupby('destination')])
    destinations, labels = zip(*sorted(zip(destinations, labels), key=lambda x: x[0], reverse=True))
    plt.figure(figsize=(10, 5))
    matplotlib.rcParams['font.sans-serif'] = 'KaiTi'
    plt.pie(x=destinations, labels=destinations, autopct='%1.1f%%')
    plt.title('毕业去向占比图')
    plt.legend(labels=labels, bbox_to_anchor=(1, 1))
    plt.show()
